﻿using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Collections.Generic;
using System.Text;
using DiscoveryLogic.DataServices.DataObjects.Entities;

namespace DiscoveryLogic.DataServices.Entities
{
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class PersonService: IPersonService
    {
        /// <summary> 
        /// test, when "Person" is not marked DataContract attribute, how it behaves
        /// </summary>
        /// <param name="searchKey"></param>
        /// <returns></returns>
        public List<Person> GetPersons(SearchKey searchKey)
        {
            List<Person> persons = new List<Person>();
            for (int i = 0; i < 100; i++)
            {
                persons.Add(
                    new Person(Guid.NewGuid(), EntityType.Person, "person")
                        {
                            Associations = new List<Association>(),
                            BirthDate = new DateTime(1980, 1, 1),
                            Email = string.Format("person{0}@domain.com", i + 1),
                            FirstName = string.Format("first {0}", i),
                            Gender = Gender.Male,
                            LastName = "Last",
                            MidName = "M",
                            Navigations = new List<Navigation>(),
                            Race = Race.White
                        });
            }

            persons.Add(
                new Person(Guid.NewGuid(), EntityType.Person, "person")
                    {
                        Associations = new List<Association>(),
                        BirthDate = new DateTime(1980, 1, 1),
                        Email = "person@domain.com",
                        FirstName = "first",
                        Gender = Gender.Male,
                        LastName = "Last",
                        MidName = "M",
                        Navigations = new List<Navigation>(),
                        Race = Race.White
                    });
            persons.Add(
                new Person(Guid.NewGuid(), EntityType.Person, "person")
                    {
                        Associations = new List<Association>(),
                        BirthDate = new DateTime(1980, 1, 1),
                        Email = "person@domain.com",
                        FirstName = "first",
                        Gender = Gender.Male,
                        LastName = "Last",
                        MidName = "M",
                        Navigations = new List<Navigation>(),
                        Race = Race.White
                    });
            return persons;
        }

        //public List<Person> EndGetPersons(IAsyncResult result)
        //{
        //    delegate call

        //}

        //IAsyncResult IPersonService.GetPersons(SearchKey searchKey, AsyncCallback callback, object state)
        //{
        //    throw new NotImplementedException();
        //}
    }
}
